package o20sametree;

import o19treeinfixorder.TreeInfixOrder;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shkstart
 * @create 2022-01-18-19:38
 */
public class SameTree {
    public List<Integer> inorderTraversal(TreeInfixOrder.TreeNode root) {
        if(root == null){
            return null;
        }
        List<Integer> res = new ArrayList<>();
        inorder(root,res);
        return res;
    }
    public static void inorder (TreeInfixOrder.TreeNode root, List<Integer> res) {
        if (root == null) {
            return;
        }
        inorder(root.left,res);
        res.add(root.val);
        inorder(root.right,res);
    }


    class TreeNode {
        int val;
        TreeInfixOrder.TreeNode left;
        TreeInfixOrder.TreeNode right;
        TreeNode() {}
        TreeNode(int val) { this.val = val; }
        TreeNode(int val, TreeInfixOrder.TreeNode left, TreeInfixOrder.TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}
